cmake_minimum_required(VERSION 3.16)
add_definitions( -lwiringPi  )
project(LibcameraOpenCVDemo)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# 查找OpenCV
find_package(OpenCV REQUIRED)

find_library(WIRINGPI_LIBRARIES NAMES wiringPi)
# 使用pkg-config查找libcamera
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBCAMERA REQUIRED libcamera)

# 查找Qt5
find_package(Qt5 REQUIRED COMPONENTS Core)

# 包含目录
include_directories(
    ${CMAKE_SOURCE_DIR}/include
    ${OpenCV_INCLUDE_DIRS}
    ${LIBCAMERA_INCLUDE_DIRS}
    ${Qt5Core_INCLUDE_DIRS}
)

# 添加可执行文件
add_executable(${PROJECT_NAME}
    src/config.cpp
    src/main.cpp
    src/camera.cpp
    src/chessbox.cpp
    src/Game.cpp
    src/serial.cpp
    src/filter_new.cpp
)

# 链接库
target_link_libraries(${PROJECT_NAME} PRIVATE
    ${OpenCV_LIBS}
    ${LIBCAMERA_LIBRARIES}
    Qt5::Core
)

target_link_libraries(${PROJECT_NAME} PRIVATE ${WIRINGPI_LIBRARIES}  -lpthread) 
# 启用自动MOC
set(CMAKE_AUTOMOC ON)